<template>
  <div class="dev-navigation" v-if="isDev">
    <div class="nav-toggle" @click="toggleNav">
      <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor">
        <path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/>
      </svg>
    </div>
    
    <div class="nav-menu" :class="{ 'nav-menu-open': isOpen }">
      <div class="nav-header">
        <h3>开发导航</h3>
        <button @click="toggleNav" class="close-btn">×</button>
      </div>
      
      <div class="nav-links">
        <router-link to="/" class="nav-link" @click="closeNav">
          🏠 主页
        </router-link>
        
        <router-link to="/chat" class="nav-link" @click="closeNav">
          💬 聊天页面
        </router-link>
        
        <router-link to="/conversation" class="nav-link" @click="closeNav">
          📝 对话页面
        </router-link>
        
        <router-link to="/test-suggestions" class="nav-link" @click="closeNav">
          🧪 建议问题测试
        </router-link>
      </div>
      
      <div class="nav-info">
        <div class="info-item">
          <span class="label">当前路由:</span>
          <span class="value">{{ $route.path }}</span>
        </div>
        <div class="info-item">
          <span class="label">环境:</span>
          <span class="value">{{ mode }}</span>
        </div>
      </div>
    </div>
    
    <div class="nav-overlay" :class="{ 'nav-overlay-open': isOpen }" @click="closeNav"></div>
  </div>
</template>

<script setup lang="ts">
import { ref, computed } from 'vue'

const isOpen = ref(false)

// 检查是否为开发环境
const isDev = computed(() => {
  return import.meta.env.DEV || import.meta.env.MODE === 'development'
})

const mode = computed(() => {
  return import.meta.env.MODE || 'production'
})

const toggleNav = () => {
  isOpen.value = !isOpen.value
}

const closeNav = () => {
  isOpen.value = false
}
</script>

<style scoped>
.dev-navigation {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
}

.nav-toggle {
  width: 50px;
  height: 50px;
  background: #4f46e5;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
  transition: all 0.3s ease;
}

.nav-toggle:hover {
  background: #4338ca;
  transform: scale(1.05);
}

.nav-menu {
  position: fixed;
  top: 0;
  right: -350px;
  width: 320px;
  height: 100vh;
  background: white;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
  border-left: 1px solid #e5e7eb;
}

.nav-menu-open {
  right: 0;
}

.nav-header {
  padding: 20px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
}

.nav-header h3 {
  margin: 0;
  color: #374151;
  font-size: 18px;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: #6b7280;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.close-btn:hover {
  background: #e5e7eb;
  color: #374151;
}

.nav-links {
  flex: 1;
  padding: 20px 0;
  overflow-y: auto;
}

.nav-link {
  display: block;
  padding: 12px 20px;
  color: #374151;
  text-decoration: none;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

.nav-link:hover {
  background: #f3f4f6;
  color: #4f46e5;
  border-left-color: #4f46e5;
}

.nav-link.router-link-active {
  background: #eef2ff;
  color: #4f46e5;
  border-left-color: #4f46e5;
  font-weight: 500;
}

.nav-info {
  padding: 20px;
  border-top: 1px solid #e5e7eb;
  background: #f8fafc;
}

.info-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 14px;
}

.info-item:last-child {
  margin-bottom: 0;
}

.label {
  color: #6b7280;
  font-weight: 500;
}

.value {
  color: #374151;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  background: #e5e7eb;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
}

.nav-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.nav-overlay-open {
  opacity: 1;
  visibility: visible;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .nav-menu {
    width: 280px;
    right: -300px;
  }
  
  .nav-toggle {
    width: 45px;
    height: 45px;
    top: 15px;
    right: 15px;
  }
}

/* 滚动条样式 */
.nav-links::-webkit-scrollbar {
  width: 4px;
}

.nav-links::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.nav-links::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 2px;
}

.nav-links::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
</style> 